---
title: "Connection Types"
description: "Understanding STDIO, HTTP, and WebSocket connections"
icon: "cable"
---

MCP servers communicate with clients using different transport protocols. The mcp-use client supports multiple connection types, each optimized for different use cases and deployment scenarios.

## Overview

The client supports three primary connection types:

- **STDIO**: Local process communication via standard input/output
- **HTTP/SSE**: Remote servers via HTTP with Server-Sent Events
- **WebSocket**: Bidirectional streaming communication

<Tip>
The connection type is automatically detected based on your server configuration. You don't need to specify it explicitly - just provide the appropriate parameters (command for STDIO, url for HTTP/WebSocket).
</Tip>

## STDIO (Standard Input/Output)

STDIO connections launch and manage MCP servers as local child processes, communicating through standard input and output streams.

### When to Use STDIO

- **Local development**: Testing servers on your local machine
- **Security-sensitive operations**: No network exposure required
- **File system access**: Direct access to local files and resources
- **Simple deployment**: No need for network configuration

### Characteristics

- Servers run as child processes
- Communication via stdin/stdout
- Automatic process lifecycle management
- Zero network latency
- No external dependencies

### Configuration Example:

```json
{
  "mcpServers": {
    "stdio_server": {
      "command": "npx",
      "args": ["@my-mcp/server"],
      "env": {}
    }
  }
}
```

## HTTP/SSE (Server-Sent Events)

HTTP connections communicate with MCP servers over standard HTTP/HTTPS protocols, using Server-Sent Events for real-time updates.

### When to Use HTTP

- **Remote servers**: Connecting to servers hosted elsewhere
- **Production deployment**: Servers behind load balancers or API gateways
- **Authentication**: Servers requiring OAuth or API key authentication
- **Scalability**: Multiple clients connecting to the same server

### Characteristics

- Servers accessible via HTTP(S) endpoints
- Support for custom headers (authentication, etc.)
- Compatible with standard web infrastructure
- Server-Sent Events for notifications

### Configuration Example:

```json
{
  "mcpServers": {
    "http_server": {
      "url": "http://localhost:3000",
      "headers": {
        "Authorization": "Bearer ${AUTH_TOKEN}"
      }
    }
  }
}
```

## Connection Type Selection

The client automatically detects the appropriate connection type based on your configuration:

| Configuration | Connection Type | Use Case |
|--------------|----------------|----------|
| `command` + `args` | STDIO | Local process servers |
| `url: http://...` | HTTP/SSE | Remote HTTP servers |
| `url: ws://...` | WebSocket | WebSocket servers |

<Info>
**Automatic Detection**: You never need to specify the connection type explicitly. The client analyzes your configuration and selects the appropriate transport protocol automatically.
</Info>

## Best Practices

### For Development

Use STDIO connections for local development:
- Faster iteration with direct process control
- No network configuration needed
- Easy debugging with process logs

### For Production

Use HTTP connections for production deployments:
- Better scalability and load distribution
- Support for authentication and authorization
- Compatible with existing infrastructure
- Easier monitoring and logging

### Security Considerations

- **STDIO**: Most secure, no network exposure
- **HTTP**: Use HTTPS in production, implement authentication
- **WebSocket**: Use WSS (WebSocket Secure) for encrypted connections

## Next Steps

<CardGroup cols={2}>
  <Card title="Client Configuration" icon="cog" href="/typescript/client/client-configuration">
    Learn about all configuration options
  </Card>
  <Card title="Multi-Server Setup" icon="network" href="/typescript/client/multi-server-setup">
    Connect to multiple servers simultaneously
  </Card>
  <Card title="Authentication" icon="shield" href="/typescript/client/authentication">
    Secure your connections with OAuth
  </Card>
  <Card title="Sandbox Mode" icon="box" href="/typescript/client/sandbox">
    Secure execution environment for code
  </Card>
</CardGroup>
